package org.wmq.shopmanager.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.wmq.commonutil.result.Result;
import org.wmq.shopmanager.service.SystemRoleMenuService;
import org.wmq.shopmodel.DTO.system.SystemRoleMenuAssignDTO;
import org.wmq.shopmodel.VO.system.SystemRoleMenuListVO;

@RestController
@RequestMapping("/admin/system/system-role-menu")
@RequiredArgsConstructor
public class SystemRoleMenuController {
    private final SystemRoleMenuService systemRoleMenuService;

    @GetMapping("/getAllMenuAndAssignedRoleMenu/{roleId}")
    public Result<SystemRoleMenuListVO> getAllMenuAndAssignedRoleMenu(@PathVariable Long roleId) {
        SystemRoleMenuListVO systemRoleMenuListVO = this.systemRoleMenuService.getAllMenuAndAssignedRoleMenu(roleId);
        return Result.success(systemRoleMenuListVO);
    }

    @PostMapping
    public Result<Void> assignMenuToRole(@RequestBody SystemRoleMenuAssignDTO systemRoleMenuAssignDTO){
        this.systemRoleMenuService.assignMenuToRole(systemRoleMenuAssignDTO);
        return Result.success();
    }
}
